﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Pb;
public class DDZCardCompare : MonoBehaviour {

    /**
        *4带2对子 isSelectCardCanPut
        * 提示 4带2对子
     */
    #region 斗地主

    #region isSelectCardCanPut 

    public static bool isSelectCardCanPut(List<int> myCards,POKER_TYPE myCardType, List<int> lastCards, POKER_TYPE lastCardTye)
    {
        // 我的牌和上家的牌都不能为null
        if (myCards == null || lastCards == null)
        {
            return false;
        }

        if (myCardType == null || lastCardTye == null)
        {
            Debug.Log("上家出的牌不合法，所以不能出。");
            return false;
        }

        // 上一首牌的个数
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;

        // 我先出牌，上家没有牌
        if (prevSize == 0 && mySize != 0)
        {
            return true;
        }

        // 集中判断是否王炸，免得多次判断王炸
        if (lastCardTye == POKER_TYPE.KingBomb)
        {
            Debug.Log("上家王炸，肯定不能出。");
            return false;
        }
        else if (myCardType == POKER_TYPE.KingBomb)
        {
            Debug.Log("我王炸，肯定能出。");
            return true;
        }

        // 集中判断对方不是炸弹，我出炸弹的情况
        if (lastCardTye != POKER_TYPE.FourBomb && myCardType == POKER_TYPE.FourBomb)
        {
            return true;
        }

        //所有牌提前排序过了

        int myGrade = myCards[0];
        int prevGrade = lastCards[0];

        // 比较2家的牌，主要有2种情况，1.我出和上家一种类型的牌，即对子管对子；
        // 2.我出炸弹，此时，和上家的牌的类型可能不同
        // 王炸的情况已经排除

        // 单
        if (lastCardTye == POKER_TYPE.Single && myCardType == POKER_TYPE.Single)
        {
            // 一张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);
        }
        // 对子
        else if (lastCardTye == POKER_TYPE.Twin
                && myCardType == POKER_TYPE.Twin)
        {
            // 2张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);

        }
        // 3不带
        else if (lastCardTye == POKER_TYPE.Triple
                && myCardType == POKER_TYPE.Triple)
        {
            // 3张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);
        }
        // 炸弹
        else if (lastCardTye == POKER_TYPE.FourBomb
                && myCardType == POKER_TYPE.FourBomb)
        {
            // 4张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);

        }
        // 3带1
        else if (lastCardTye == POKER_TYPE.TripleWithSingle)
        {

            // 3带1只需比较第2张牌的大小
            myGrade = myCards[1];
            prevGrade = lastCards[1];
            return compareGrade(myGrade, prevGrade);

        }
        else if (lastCardTye == POKER_TYPE.TripleWithTwin)
        {

            // 3带2只需比较第3张牌的大小
            myGrade = myCards[2];
            prevGrade = lastCards[2];
            return compareGrade(myGrade, prevGrade);

        }
        
        // 4带2
        else if (lastCardTye == POKER_TYPE.FourWithSingle
                && myCardType == POKER_TYPE.FourWithSingle)
        {

            // 4带2只需比较第3张牌的大小
            myGrade = myCards[2];
            prevGrade = lastCards[2];
            return compareGrade(myGrade, prevGrade);
        }
        // 4带2对子
        else if (lastCardTye == POKER_TYPE.FourWithTwin
                && myCardType == POKER_TYPE.FourWithTwin)
        {
            Hashtable myHashCards = SortCardUseHash1(myCards);
            Hashtable prevHashCards = SortCardUseHash1(lastCards);
            foreach (int key in myHashCards.Keys)
            {
                if ((int)myHashCards[key] == 4) {
                    myGrade =  key;
                }
            }
            foreach (int key in prevHashCards.Keys)
            {
                if ((int)prevHashCards[key] == 4)
                {
                    prevGrade = key;
                }
            }
            return compareGrade(myGrade, prevGrade);

        }
        // 顺子
        else if (lastCardTye == POKER_TYPE.StraightSingle
                && myCardType == POKER_TYPE.StraightSingle)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                // 顺子只需比较最大的1张牌的大小
                myGrade = myCards[mySize-1];
                prevGrade = lastCards[prevSize - 1];
                return compareGrade(myGrade, prevGrade);
            }

        }
        // 连对
        else if (lastCardTye == POKER_TYPE.StraightTwin
                && myCardType == POKER_TYPE.StraightTwin)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                // 顺子只需比较最大的1张牌的大小
                myGrade = myCards[mySize - 1];
                prevGrade = lastCards[prevSize - 1];
                return compareGrade(myGrade, prevGrade);
            }

        }
        // 飞机不带
        else if (lastCardTye == POKER_TYPE.PlanePure
                && myCardType == POKER_TYPE.PlanePure)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                //333444555666算飞机不带 不算飞机带单
                myGrade = myCards[4];
                prevGrade = lastCards[4];
                return compareGrade(myGrade, prevGrade);
            }
        }
        //飞机带单
        else if (lastCardTye == POKER_TYPE.PlaneWithSingle
                && myCardType == POKER_TYPE.PlaneWithSingle)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                List<int> tempThreeList = new List<int>();
                for (int i = 0; i < myCards.Count; i++)
                {
                    int tempInt = 0;
                    for (int j = 0; j < myCards.Count; j++)
                    {

                        if (myCards[i] == myCards[j])
                        {
                            tempInt++;
                        }

                    }
                    if (tempInt == 3)
                    {
                        tempThreeList.Add(myCards[i]);
                    }
                }
                myGrade = tempThreeList[4];
                prevGrade = lastCards[4];
                return compareGrade(myGrade, prevGrade);
            }
        }
        //飞机带双
        else if (lastCardTye == POKER_TYPE.PlaneWithTwin
                && myCardType == POKER_TYPE.PlaneWithTwin)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                List<int> tempThreeList = new List<int>();
                List<int> tempTwoList = new List<int>();
                for (int i = 0; i < myCards.Count; i++)
                {
                    int tempInt = 0;
                    for (int j = 0; j < myCards.Count; j++)
                    {

                        if (myCards[i] == myCards[j])
                        {
                            tempInt++;
                        }

                    }
                    if (tempInt == 3)
                    {
                        tempThreeList.Add(myCards[i]);
                    }
                    else if (tempInt == 2)
                    {
                        tempTwoList.Add(myCards[i]);
                    }

                }
                myGrade = tempThreeList[4];
                prevGrade = lastCards[4];
                if (compareGrade(myGrade, prevGrade))
                {
                    return DDZCardRule.IsAllDouble(tempTwoList);
                }
            }
        }

        // 默认不能出牌
        return false;
    }
    #endregion


    #region isShowOutCardBtn

    public static bool isShowOutCardBtn(List<int> myCards,
            List<int> lastCards, POKER_TYPE lastCardType)
    {

        
        // 上一首牌的个数
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;

        // 我先出牌，上家没有牌
        if (prevSize == 0 && mySize != 0)
        {
            return true;
        }

        // 集中判断是否王炸，免得多次判断王炸
        if (lastCardType == POKER_TYPE.KingBomb)
        {
            Debug.Log("上家王炸，肯定不能出。");
            return false;
        }

        if (mySize >= 2)
        {
            List<int> cards = new List<int>();
            cards.Add(myCards[mySize - 1]);
            cards.Add(myCards[mySize - 2]);
            if (DDZCardRule.IsJokerBoom(cards))
            {
                return true;
            }
        }

        // 集中判断对方不是炸弹，我出炸弹的情况
        if (lastCardType != POKER_TYPE.FourBomb)
        {
            //if (mySize < 4)           //SbBug  害的我找半天
            //{
            //    Debug.Log("炸弹false");
            //    return false;
            //}
            if (mySize >= 4) {
                for (int i = 0; i < mySize - 3; i++)
                {
                    int grade0 = myCards[i];
                    int grade1 = myCards[i + 1];
                    int grade2 = myCards[i + 2];
                    int grade3 = myCards[i + 3];

                    if (grade1 == grade0 && grade2 == grade0
                            && grade3 == grade0)
                    {
                        return true;
                    }
                }
            }
               
        }

        int prevGrade = lastCards[0];
        Debug.Log("prevGrade"+prevGrade);

        // 比较2家的牌，主要有2种情况，1.我出和上家一种类型的牌，即对子管对子；
        // 2.我出炸弹，此时，和上家的牌的类型可能不同
        // 王炸的情况已经排除

        // 上家出单
        if (lastCardType == POKER_TYPE.Single)
        {
            // 一张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 0; i--)
            {
                int grade = myCards[i];
                //Debug.Log("grade" + grade);
                if (grade > prevGrade)
                {
                    // 只要有1张牌可以大过上家，则返回true
                    return true;
                }
            }

        }
        // 上家出对子
        else if (lastCardType == POKER_TYPE.Twin)
        {
            // 2张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 1; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i-1];

                if (grade0 == grade1)
                {
                    if (grade0 > prevGrade)
                    {
                        // 只要有1对牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出3不带
        else if (lastCardType == POKER_TYPE.Triple)
        {
            // 3张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 2; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];

                if (grade0 == grade1 && grade0 == grade2)
                {
                    if (grade0 > prevGrade)
                    {
                        // 只要3张牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出3带1
        else if (lastCardType == POKER_TYPE.TripleWithSingle)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 4)
            {
                return false;
            }

            // 3张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 2; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];

                if (grade0 == grade1 && grade0 == grade2)
                {
                    if (grade0 > lastCards[1])
                    {
                        // 只要3张牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出3带2
        else if (lastCardType == POKER_TYPE.TripleWithTwin)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 5)
            {
                return false;
            }

            // 3张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 2; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];

                if (grade0 == grade1 && grade0 == grade2)
                {
                    if (grade0 > lastCards[2])
                    {
                        // 只要3张牌可以大过上家，则返回true      ----------------------------这里需要判断除了这三张是否拥有对子
                        myCards.RemoveAt(i);
                        myCards.RemoveAt(i-1);
                        myCards.RemoveAt(i - 2);
                        for (int j = myCards.Count - 1; j >= 1; j--) {
                            int temp0 = myCards[j];
                            int temp1= myCards[j-1];
                            if (temp0 == temp1)
                            {
                                return true;
                            }
                        }
                    }
                }
            }

        }
        // 上家出炸弹
        else if (lastCardType == POKER_TYPE.FourBomb)
        {
            // 4张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 3; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];
                int grade3 = myCards[i - 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    if (grade0 > prevGrade)
                    {
                        // 只要有4张牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出4带2 
        else if (lastCardType == POKER_TYPE.FourWithSingle)
        {
            // 4张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 3; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];
                int grade3 = myCards[i - 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    // 只要有炸弹，则返回true
                    return true;
                }
            }
        }
        // 上家出顺子
        else if (lastCardType == POKER_TYPE.StraightSingle)
        {
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
               
                Hashtable myCardsHash = SortCardUseHash(myCards);
                if (myCardsHash.Count< prevSize) {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");
                    return false;
                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++) {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1-i+j]);
                    }
                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    //是不是顺子
                    //Debug.Log();
                    if (myCardType == POKER_TYPE.StraightSingle)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后

                        if (myGrade2 > prevGrade2)
                        {
                            return true;
                        }
                    }
                }

                //List<int> hashKey=
                //foreach (DictionaryEntry de in myCardsHash)
                //{
                   
                //}
            }

        }
        // 上家出连对
        else if (lastCardType == POKER_TYPE.StraightTwin)
        {
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
                Hashtable myCardsHash = SortCardUseHash(myCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");
                    return false;
                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                for (int i = myCardsHashKey.Count - 1; i >= prevSize/2 - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize/2; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    bool tempBool = false;

                    for (int j = 0; j < cards.Count - 1; j++)
                    {
                        int w = cards[j];
                        if (cards[j + 1] - w == 1 && (int)myCardsHash[cards[j]] >= 2 && (int)myCardsHash[cards[j + 1]] >= 2)
                        {
                            tempBool = true;
                        }
                        else
                        {
                            tempBool = false;
                            break;
                        }
                    }
                    if (tempBool) {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后
                        if (myGrade2> prevGrade2) {
                            return true;
                        }
                    }
                }
            }

        }
        //上家出飞机
        else if (lastCardType == POKER_TYPE.PlanePure)
        {
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
                for (int i = 0; i <= mySize - prevSize; i++)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            return true;
                        }
                    }
                }
            }
        }
        
        //上家出飞机带单
        else if (lastCardType == POKER_TYPE.PlaneWithSingle)
        {
            Hashtable tempMyCardHash = SortCardUseHash1(myCards);
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
                int findTimes = mySize - prevSize + prevSize / 4;
                int feijiCount = prevSize - (prevSize / 4);
                for (int i = 0; i <= findTimes; i++)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            return true;
                        }
                    }
                }
            }
        }

        //上家出飞机带双
        else if (lastCardType == POKER_TYPE.PlaneWithTwin)
        {
            Hashtable tempMyCardHash = SortCardUseHash1(myCards);
            if (mySize < prevSize)
            {

            }
            else
            {
                
                int findTimes = mySize - prevSize + (prevSize / 5) * 2;
                int feijiCount = prevSize - (prevSize / 5) * 2;
                for (int i = 0; i <= findTimes; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            for (int ii = 0; ii < cards.Count; ii+=3) {
                                if (tempMyCardHash.Contains(cards[ii]))
                                {
                                    tempMyCardHash.Remove(cards[ii]);
                                }
                            }                 
                            
                            int iii = 0;
                            
                            foreach (int key in tempMyCardHash.Keys)
                            {
                                if (int.Parse(tempMyCardHash[key].ToString()) >= 2)
                                {
                                    cards.Add(key);
                                    cards.Add(key);
                                    iii++;
                                    if (iii == prevSize / 5)
                                    {
                                        return true;
                                        
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // 默认不能出牌
        return false;
    }
    #endregion


    #region 提示出牌 
    public static Dictionary<int, List<int>> FindPromptCards(List<int> myCards, 
        List<int> lastCards, POKER_TYPE lastCardType) {
        Dictionary<int, List<int>> PromptCards = new Dictionary<int, List<int>>();
        Hashtable tempMyCardHash = SortCardUseHash1(myCards);

        // 上一首牌的个数
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;
        
        // 我先出牌，上家没有牌
        if (prevSize == 0 && mySize != 0)
        {
            //把所有牌权重存入返回
            Debug.Log("上家没有牌");
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++) {
                List<int> tempIntList = new List<int>();
                tempIntList.Add(myCardsHashKey[i]);
                PromptCards.Add(i, tempIntList);
                
            }
        }

        // 集中判断是否王炸，免得多次判断王炸
        if (lastCardType == POKER_TYPE.KingBomb)
        {
            Debug.Log("上家王炸，肯定不能出。");
            
        }
        int prevGrade = 0;
        if (prevSize > 0) {
            prevGrade = lastCards[0];
            Debug.Log("prevGrade" + prevGrade);
        }

       

        // 比较2家的牌，主要有2种情况，1.我出和上家一种类型的牌，即对子管对子；
        // 2.我出炸弹，此时，和上家的牌的类型可能不同
        // 王炸的情况已经排除

        // 上家出单
        if (lastCardType == POKER_TYPE.Single)
        {
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > prevGrade){
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }
               

            }
           

        }
        // 上家出对子
        else if (lastCardType == POKER_TYPE.Twin)
        {
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > prevGrade&& (int)tempMyCardHash[myCardsHashKey[i]]>=2)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出3不带
        else if (lastCardType == POKER_TYPE.Triple)
        {
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出3带1
        else if (lastCardType == POKER_TYPE.TripleWithSingle)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 4)
            {
                
            }
            int grade3=0;
            foreach (int key in tempMyCardHash.Keys)
            {
                if (int.Parse(tempMyCardHash[key].ToString()) == 1) {
                    grade3 = key;
                    break;
                }
            }
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > lastCards[1] && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(grade3);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出3带2
        else if (lastCardType == POKER_TYPE.TripleWithTwin)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 5)
            {
                
            }
            int grade3 = 0;
            int grade4 = 0;
            foreach (int key in tempMyCardHash.Keys)
            {
                if (int.Parse(tempMyCardHash[key].ToString()) == 2)
                {
                    grade3 = key;
                    grade4 = key;
                    break;
                }
            }
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > lastCards[2] && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(grade3);
                    tempIntList.Add(grade4);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出炸弹
        else if (lastCardType == POKER_TYPE.FourBomb)
        {
            int tempCount = 0;
            // 4张牌可以大过上家的牌
            for (int i = 0; i <= mySize - 4; i++)
            {
                
                int grade0 = myCards[i];
                int grade1 = myCards[i + 1];
                int grade2 = myCards[i + 2];
                int grade3 = myCards[i + 3];


                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    if (grade0 > prevGrade)
                    {
                        // 把四张牌存进去
                        List<int> tempIntList = new List<int>();
                        tempIntList.Add(grade0);
                        tempIntList.Add(grade1);
                        tempIntList.Add(grade2);
                        tempIntList.Add(grade3);
                        
                        PromptCards.Add(tempCount, tempIntList);
                        tempCount++;
                    }
                }
            }

        }
        // 上家出4带2 
        else if (lastCardType == POKER_TYPE.FourWithSingle)
        {
            Hashtable lastCardHash = SortCardUseHash1(lastCards);
            int lastCard4 = 0;
            foreach (int key in lastCardHash.Keys)
            {
                if ((int)lastCardHash[key] == 4) {
                    lastCard4 = key;
                }
            }

            int tempCount = 0;
            // 4张牌可以大过上家的牌
            for (int i = 0; i <= mySize - 4; i++)
            {
                List<int> cards = new List<int>();
                int grade0 = myCards[i];
                int grade1 = myCards[i + 1];
                int grade2 = myCards[i + 2];
                int grade3 = myCards[i + 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    cards.Add(grade0);
                    cards.Add(grade1);
                    cards.Add(grade2);
                    cards.Add(grade3);
                    if (grade0 > lastCard4) {
                        int ii = 0;
                        //存进去PromptCards 然后再找一个最小的两个单
                        foreach (int key in tempMyCardHash.Keys)
                        {
                            if (int.Parse(tempMyCardHash[key].ToString()) != 4)
                            {
                                cards.Add(key);
                                ii++;
                                if (ii == 2)
                                {
                                    break;
                                }                               
                            }
                        }
                        PromptCards.Add(tempCount, cards);
                        tempCount++;
                    }
                    
                }
            }
        }
        // 上家出4带2 对子
        else if (lastCardType == POKER_TYPE.FourWithTwin)
        {
            Hashtable lastCardHash = SortCardUseHash1(lastCards);
            int lastCard4 = 0;
            foreach (int key in lastCardHash.Keys)
            {
                if ((int)lastCardHash[key] == 4)
                {
                    lastCard4 = key;
                }
            }


            // 4张牌可以大过上家的牌
            int tempCount = 0;
            for (int i =0; i <= mySize - 4; i++)
            {
                List<int> cards = new List<int>();
                int grade0 = myCards[i];
                int grade1 = myCards[i + 1];
                int grade2 = myCards[i + 2];
                int grade3 = myCards[i + 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    cards.Add(grade0);
                    cards.Add(grade1);
                    cards.Add(grade2);
                    cards.Add(grade3);
                    
                    if (grade0 > lastCard4)
                    {
                        int ii = 0;
                        
                        foreach (int key in tempMyCardHash.Keys)
                        {
                            int tempint = int.Parse(tempMyCardHash[key].ToString());
                            if (tempint >= 2 && tempint != grade0 && tempint!=4)
                            {
                                cards.Add(key);
                                cards.Add(key);
                                ii++;
                                if (ii == 2)
                                {
                                    break;
                                }
                            }
                        }
                        PromptCards.Add(tempCount, cards);
                        tempCount++;
                    }   
                }
            }
        }
        // 上家出顺子
        else if (lastCardType == POKER_TYPE.StraightSingle)
        {
            if (mySize < prevSize)
            {
                
            }
            else
            {
                List<int> tempMyCards = new List<int>();
                tempMyCards = myCards;
                Hashtable myCardsHash = SortCardUseHash(tempMyCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");
                    
                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                int tempCount = 0;
                for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    
                    if (myCardType == POKER_TYPE.StraightSingle)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后

                        if (myGrade2 > prevGrade2)
                        {
                            //存进去PromptCards
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
                
            }

        }
        // 上家出连对
        else if (lastCardType == POKER_TYPE.StraightTwin)
        {
            if(mySize < prevSize)
            {
               
            }
            else
            {
                Hashtable myCardsHash = SortCardUseHash(myCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");
                    
                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                int tempCount = 0;
                for (int i = myCardsHashKey.Count - 1; i >= prevSize / 2 - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize / 2; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    bool tempBool = false;

                    for (int j = 0; j < cards.Count - 1; j++)
                    {
                        int w = cards[j];
                        if (cards[j + 1] - w == 1 && (int)myCardsHash[cards[j]] >= 2 && (int)myCardsHash[cards[j + 1]] >= 2)
                        {
                            tempBool = true;
                        }
                        else {
                            tempBool = false;
                            break;
                        }
                    }
                    if (tempBool)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后
                        if (myGrade2 > prevGrade2)
                        {
                            for (int j = 0; j < prevSize/2; j++)
                            {
                                cards.Add(cards[j]);
                            }
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }

        }
        //上家出飞机
        else if (lastCardType == POKER_TYPE.PlanePure)
        {
            if (mySize < prevSize)
            {
                
            }
            else
            {
                int tempCount = 0;
                for (int i = 0; i <= mySize - prevSize; i++)
                {
                    
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCards[i+ j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            //存进去PromptCards
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }
        }
        //上家出飞机带单
        else if (lastCardType == POKER_TYPE.PlaneWithSingle)
        {
            if (mySize < prevSize)
            {
                
            }
            else
            {
                int tempCount = 0;
                int findTimes = mySize - prevSize + prevSize / 4;
                int feijiCount = prevSize - (prevSize / 4);
                for (int i = 0; i <= findTimes; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            Hashtable tempMyCardHash1 = SortCardUseHash1(myCards);
                            for (int ii = 0; ii < cards.Count; ii++)
                            {
                                if (tempMyCardHash1.Contains(cards[ii]))
                                {
                                    tempMyCardHash1.Remove(cards[ii]);
                                }
                            }
                            int iii = 0;
                            //存进去PromptCards 然后再找一个最小的两个单
                            foreach (int key in tempMyCardHash1.Keys)
                            {
                                if (int.Parse(tempMyCardHash1[key].ToString()) != 4) {
                                    cards.Add(key);
                                    iii++;
                                    if (iii == prevSize / 4)
                                    {
                                        break;
                                    }
                                }
                            }
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }
        }

        //上家出飞机带双
        else if (lastCardType == POKER_TYPE.PlaneWithTwin)
        {
            
            if (mySize < prevSize)
            {

            }
            else
            {
                int tempCount = 0;
                int findTimes = mySize - prevSize + (prevSize / 5) * 2;
                int feijiCount = prevSize - (prevSize / 5) * 2;
                for (int i = 0; i <= findTimes; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            Hashtable tempMyCardHash1 = SortCardUseHash1(myCards);
                            for (int ii = 0; ii < cards.Count; ii++)
                            {
                                if (tempMyCardHash1.Contains(cards[ii]))
                                {
                                    tempMyCardHash1.Remove(cards[ii]);
                                }
                            }

                            //存进去
                            int iii = 0;
                            //存进去PromptCards 然后再找一个最小的两个单
                            foreach (int key in tempMyCardHash1.Keys)
                            {
                                if (int.Parse(tempMyCardHash1[key].ToString()) >= 2)
                                {
                                    cards.Add(key);
                                    cards.Add(key);
                                    iii++;
                                    if (iii == prevSize / 5)
                                    {
                                        break;

                                    }
                                }
                            }
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }
        }




        // 集中判断对方不是炸弹，我出炸弹的情况
        if (lastCardType != POKER_TYPE.FourBomb)
        {
            
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if ( (int)tempMyCardHash[myCardsHashKey[i]] == 4)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    Debug.Log("PromptCards.Count"+PromptCards.Count);
                    PromptCards.Add(PromptCards.Count, tempIntList);
                    
                }


            }

        }
        if (mySize >= 2)
        {
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            if (myCardsHashKey.Contains(53) && myCardsHashKey.Contains(54)) {
                List<int> tempIntList = new List<int>();
                tempIntList.Add(53);
                tempIntList.Add(54);
                PromptCards.Add(PromptCards.Count, tempIntList);
            }
        }

        return PromptCards;
    }
    #endregion

    #endregion

    #region  跑的快 1判断选择的牌是否能出  2判断是否显示要不起按钮 3提示出牌

    #region isSelectCardCanPutRunFast

    public static bool isSelectCardCanPutForRunFast(List<int> myCards, POKER_TYPE myCardType, List<int> lastCards, POKER_TYPE lastCardTye)
    {
        // 我的牌和上家的牌都不能为null
        if (myCards == null || lastCards == null)
        {
            return false;
        }

        if (myCardType == null || lastCardTye == null)
        {
            Debug.Log("上家出的牌不合法，所以不能出。");
            return false;
        }

        // 上一首牌的个数
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;

        // 我先出牌，上家没有牌
        if (prevSize == 0 && mySize != 0)
        {
            return true;
        }

        // 集中判断是否王炸，免得多次判断王炸
        //if (lastCardTye == POKER_TYPE.KingBomb)
        //{
        //    Debug.Log("上家王炸，肯定不能出。");
        //    return false;
        //}
        //else if (myCardType == POKER_TYPE.KingBomb)
        //{
        //    Debug.Log("我王炸，肯定能出。");
        //    return true;
        //}

        // 集中判断对方不是炸弹，我出炸弹的情况
        if (lastCardTye != POKER_TYPE.FourBomb && myCardType == POKER_TYPE.FourBomb)
        {
            return true;
        }

        //所有牌提前排序过了

        int myGrade = myCards[0];
        int prevGrade = lastCards[0];

        // 比较2家的牌，主要有2种情况，1.我出和上家一种类型的牌，即对子管对子；
        // 2.我出炸弹，此时，和上家的牌的类型可能不同
        // 王炸的情况已经排除

        // 单
        if (lastCardTye == POKER_TYPE.Single && myCardType == POKER_TYPE.Single)
        {
            // 一张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);
        }
        // 对子
        else if (lastCardTye == POKER_TYPE.Twin
                && myCardType == POKER_TYPE.Twin)
        {
            // 2张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);

        }
        // 3不带
        else if (lastCardTye == POKER_TYPE.Triple
                && myCardType == POKER_TYPE.Triple)
        {
            // 3张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);
        }
        // 炸弹
        else if (lastCardTye == POKER_TYPE.FourBomb
                && myCardType == POKER_TYPE.FourBomb)
        {
            // 4张牌可以大过上家的牌
            return compareGrade(myGrade, prevGrade);

        }
        // 3带1
        else if (lastCardTye == POKER_TYPE.TripleWithSingle)
        {

            // 3带1只需比较第2张牌的大小
            myGrade = myCards[1];
            prevGrade = lastCards[1];
            return compareGrade(myGrade, prevGrade);

        }
        else if (lastCardTye == POKER_TYPE.TripleWithTwin)
        {

            // 3带2只需比较第3张牌的大小
            myGrade = myCards[2];
            prevGrade = lastCards[2];
            return compareGrade(myGrade, prevGrade);

        }

        // 4带2
        else if (lastCardTye == POKER_TYPE.FourWithSingle
                && myCardType == POKER_TYPE.FourWithSingle)
        {

            // 4带2只需比较第3张牌的大小
            myGrade = myCards[2];
            prevGrade = lastCards[2];
            return compareGrade(myGrade, prevGrade);
        }
        // 4带2对子
        else if (lastCardTye == POKER_TYPE.FourWithTwin
                && myCardType == POKER_TYPE.FourWithTwin)
        {
            Hashtable myHashCards = SortCardUseHash1(myCards);
            Hashtable prevHashCards = SortCardUseHash1(lastCards);
            foreach (int key in myHashCards.Keys)
            {
                if ((int)myHashCards[key] == 4)
                {
                    myGrade = key;
                }
            }
            foreach (int key in prevHashCards.Keys)
            {
                if ((int)prevHashCards[key] == 4)
                {
                    prevGrade = key;
                }
            }
            return compareGrade(myGrade, prevGrade);

        }
        // 顺子
        else if (lastCardTye == POKER_TYPE.StraightSingle
                && myCardType == POKER_TYPE.StraightSingle)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                // 顺子只需比较最大的1张牌的大小
                myGrade = myCards[mySize - 1];
                prevGrade = lastCards[prevSize - 1];
                return compareGrade(myGrade, prevGrade);
            }

        }
        // 连对
        else if (lastCardTye == POKER_TYPE.StraightTwin
                && myCardType == POKER_TYPE.StraightTwin)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                // 顺子只需比较最大的1张牌的大小
                myGrade = myCards[mySize - 1];
                prevGrade = lastCards[prevSize - 1];
                return compareGrade(myGrade, prevGrade);
            }

        }
        // 飞机不带
        else if (lastCardTye == POKER_TYPE.PlanePure
                && myCardType == POKER_TYPE.PlanePure)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                //333444555666算飞机不带 不算飞机带单
                myGrade = myCards[4];
                prevGrade = lastCards[4];
                return compareGrade(myGrade, prevGrade);
            }
        }
        //飞机带单
        else if (lastCardTye == POKER_TYPE.PlaneWithSingle
                && myCardType == POKER_TYPE.PlaneWithSingle)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                List<int> tempThreeList = new List<int>();
                for (int i = 0; i < myCards.Count; i++)
                {
                    int tempInt = 0;
                    for (int j = 0; j < myCards.Count; j++)
                    {

                        if (myCards[i] == myCards[j])
                        {
                            tempInt++;
                        }

                    }
                    if (tempInt == 3)
                    {
                        tempThreeList.Add(myCards[i]);
                    }
                }
                myGrade = tempThreeList[4];
                prevGrade = lastCards[4];
                return compareGrade(myGrade, prevGrade);
            }
        }
        //飞机带双
        else if (lastCardTye == POKER_TYPE.PlaneWithTwin
                && myCardType == POKER_TYPE.PlaneWithTwin)
        {
            if (mySize != prevSize)
            {
                return false;
            }
            else
            {
                List<int> tempThreeList = new List<int>();
                List<int> tempTwoList = new List<int>();
                for (int i = 0; i < myCards.Count; i++)
                {
                    int tempInt = 0;
                    for (int j = 0; j < myCards.Count; j++)
                    {

                        if (myCards[i] == myCards[j])
                        {
                            tempInt++;
                        }

                    }
                    if (tempInt == 3)
                    {
                        tempThreeList.Add(myCards[i]);
                    }
                    else if (tempInt == 2)
                    {
                        tempTwoList.Add(myCards[i]);
                    }

                }
                myGrade = tempThreeList[4];
                prevGrade = lastCards[4];
                if (compareGrade(myGrade, prevGrade))
                {
                    return DDZCardRule.IsAllDouble(tempTwoList);
                }
            }
        }

        // 默认不能出牌
        return false;
    }
    #endregion


    #region isShowOutCardBtnRunFast

    public static bool isShowOutCardBtnRunFast(List<int> myCards,
            List<int> lastCards, POKER_TYPE lastCardType)
    {


        // 上一首牌的个数
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;

        // 我先出牌，上家没有牌
        if (prevSize == 0 && mySize != 0)
        {
            return true;
        }

        //// 集中判断是否王炸，免得多次判断王炸
        //if (lastCardType == POKER_TYPE.KingBomb)
        //{
        //    Debug.Log("上家王炸，肯定不能出。");
        //    return false;
        //}

        //if (mySize >= 2)
        //{
        //    List<int> cards = new List<int>();
        //    cards.Add(myCards[mySize - 1]);
        //    cards.Add(myCards[mySize - 2]);
        //    if (DDZCardRule.IsJokerBoom(cards))
        //    {
        //        return true;
        //    }
        //}

        // 集中判断对方不是炸弹，我出炸弹的情况
        if (lastCardType != POKER_TYPE.FourBomb)
        {
            //if (mySize < 4)           //SbBug  害的我找半天
            //{
            //    Debug.Log("炸弹false");
            //    return false;
            //}
            if (mySize >= 4)
            {
                for (int i = 0; i < mySize - 3; i++)
                {
                    int grade0 = myCards[i];
                    int grade1 = myCards[i + 1];
                    int grade2 = myCards[i + 2];
                    int grade3 = myCards[i + 3];

                    if (grade1 == grade0 && grade2 == grade0
                            && grade3 == grade0)
                    {
                        return true;
                    }
                }
            }

        }

        int prevGrade = lastCards[0];
        Debug.Log("prevGrade" + prevGrade);

        // 比较2家的牌，主要有2种情况，1.我出和上家一种类型的牌，即对子管对子；
        // 2.我出炸弹，此时，和上家的牌的类型可能不同
        // 王炸的情况已经排除

        // 上家出单
        if (lastCardType == POKER_TYPE.Single)
        {
            // 一张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 0; i--)
            {
                int grade = myCards[i];
                //Debug.Log("grade" + grade);
                if (grade > prevGrade)
                {
                    // 只要有1张牌可以大过上家，则返回true
                    return true;
                }
            }

        }
        // 上家出对子
        else if (lastCardType == POKER_TYPE.Twin)
        {
            // 2张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 1; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];

                if (grade0 == grade1)
                {
                    if (grade0 > prevGrade)
                    {
                        // 只要有1对牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出3不带
        else if (lastCardType == POKER_TYPE.Triple)
        {
            // 3张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 2; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];

                if (grade0 == grade1 && grade0 == grade2)
                {
                    if (grade0 > prevGrade)
                    {
                        // 只要3张牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出3带1
        else if (lastCardType == POKER_TYPE.TripleWithSingle)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 4)
            {
                return false;
            }

            // 3张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 2; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];

                if (grade0 == grade1 && grade0 == grade2)
                {
                    if (grade0 > lastCards[1])
                    {
                        // 只要3张牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出3带2
        else if (lastCardType == POKER_TYPE.TripleWithTwin)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 5)
            {
                return false;
            }

            // 3张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 2; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];

                if (grade0 == grade1 && grade0 == grade2)
                {
                    if (grade0 > lastCards[2])
                    {
                        // 只要3张牌可以大过上家，则返回true      ----------------------------这里需要判断除了这三张是否拥有对子
                        myCards.RemoveAt(i);
                        myCards.RemoveAt(i - 1);
                        myCards.RemoveAt(i - 2);
                        for (int j = myCards.Count - 1; j >= 1; j--)
                        {
                            int temp0 = myCards[j];
                            int temp1 = myCards[j - 1];
                            if (temp0 == temp1)
                            {
                                return true;
                            }
                        }
                    }
                }
            }

        }
        // 上家出炸弹
        else if (lastCardType == POKER_TYPE.FourBomb)
        {
            // 4张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 3; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];
                int grade3 = myCards[i - 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    if (grade0 > prevGrade)
                    {
                        // 只要有4张牌可以大过上家，则返回true
                        return true;
                    }
                }
            }

        }
        // 上家出4带2 
        else if (lastCardType == POKER_TYPE.FourWithSingle)
        {
            // 4张牌可以大过上家的牌
            for (int i = mySize - 1; i >= 3; i--)
            {
                int grade0 = myCards[i];
                int grade1 = myCards[i - 1];
                int grade2 = myCards[i - 2];
                int grade3 = myCards[i - 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    // 只要有炸弹，则返回true
                    return true;
                }
            }
        }
        // 上家出顺子
        else if (lastCardType == POKER_TYPE.StraightSingle)
        {
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {

                Hashtable myCardsHash = SortCardUseHash(myCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");
                    return false;
                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    //是不是顺子
                    //Debug.Log();
                    if (myCardType == POKER_TYPE.StraightSingle)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后

                        if (myGrade2 > prevGrade2)
                        {
                            return true;
                        }
                    }
                }

                //List<int> hashKey=
                //foreach (DictionaryEntry de in myCardsHash)
                //{

                //}
            }

        }
        // 上家出连对
        else if (lastCardType == POKER_TYPE.StraightTwin)
        {
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
                Hashtable myCardsHash = SortCardUseHash(myCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");
                    return false;
                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                for (int i = myCardsHashKey.Count - 1; i >= prevSize / 2 - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize / 2; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    bool tempBool = false;

                    for (int j = 0; j < cards.Count - 1; j++)
                    {
                        int w = cards[j];
                        if (cards[j + 1] - w == 1 && (int)myCardsHash[cards[j]] >= 2 && (int)myCardsHash[cards[j + 1]] >= 2)
                        {
                            tempBool = true;
                        }
                        else
                        {
                            tempBool = false;
                            break;
                        }
                    }
                    if (tempBool)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后
                        if (myGrade2 > prevGrade2)
                        {
                            return true;
                        }
                    }
                }
            }

        }
        //上家出飞机
        else if (lastCardType == POKER_TYPE.PlanePure)
        {
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
                for (int i = 0; i <= mySize - prevSize; i++)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            return true;
                        }
                    }
                }
            }
        }

        //上家出飞机带单
        else if (lastCardType == POKER_TYPE.PlaneWithSingle)
        {
            Hashtable tempMyCardHash = SortCardUseHash1(myCards);
            if (mySize < prevSize)
            {
                return false;
            }
            else
            {
                int findTimes = mySize - prevSize + prevSize / 4;
                int feijiCount = prevSize - (prevSize / 4);
                for (int i = 0; i <= findTimes; i++)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            return true;
                        }
                    }
                }
            }
        }

        //上家出飞机带双
        else if (lastCardType == POKER_TYPE.PlaneWithTwin)
        {
            Hashtable tempMyCardHash = SortCardUseHash1(myCards);
            if (mySize < prevSize)
            {

            }
            else
            {

                int findTimes = mySize - prevSize + (prevSize / 5) * 2;
                int feijiCount = prevSize - (prevSize / 5) * 2;
                for (int i = 0; i <= findTimes; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            for (int ii = 0; ii < cards.Count; ii += 3)
                            {
                                if (tempMyCardHash.Contains(cards[ii]))
                                {
                                    tempMyCardHash.Remove(cards[ii]);
                                }
                            }

                            int iii = 0;

                            foreach (int key in tempMyCardHash.Keys)
                            {
                                if (int.Parse(tempMyCardHash[key].ToString()) >= 2)
                                {
                                    cards.Add(key);
                                    cards.Add(key);
                                    iii++;
                                    if (iii == prevSize / 5)
                                    {
                                        return true;

                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
        // 默认不能出牌
        return false;
    }
    #endregion


    #region 提示出牌 RunFast
    public static Dictionary<int, List<int>> FindPromptCardsRunFast(List<int> myCards,
        List<int> lastCards, POKER_TYPE lastCardType)
    {
        Dictionary<int, List<int>> PromptCards = new Dictionary<int, List<int>>();
        Hashtable tempMyCardHash = SortCardUseHash1(myCards);

        // 上一首牌的个数
        int prevSize = lastCards.Count;
        int mySize = myCards.Count;

        // 我先出牌，上家没有牌
        if (prevSize == 0 && mySize != 0)
        {
            //把所有牌权重存入返回
            Debug.Log("上家没有牌");
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                List<int> tempIntList = new List<int>();
                tempIntList.Add(myCardsHashKey[i]);
                PromptCards.Add(i, tempIntList);

            }
        }

        // 集中判断是否王炸，免得多次判断王炸
        //if (lastCardType == POKER_TYPE.KingBomb)
        //{
        //    Debug.Log("上家王炸，肯定不能出。");

        //}
        int prevGrade = 0;
        if (prevSize > 0)
        {
            prevGrade = lastCards[0];
            Debug.Log("prevGrade" + prevGrade);
        }



        // 比较2家的牌，主要有2种情况，1.我出和上家一种类型的牌，即对子管对子；
        // 2.我出炸弹，此时，和上家的牌的类型可能不同
        // 王炸的情况已经排除

        // 上家出单
        if (lastCardType == POKER_TYPE.Single)
        {
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > prevGrade)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }


        }
        // 上家出对子
        else if (lastCardType == POKER_TYPE.Twin)
        {
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 2)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出3不带
        else if (lastCardType == POKER_TYPE.Triple)
        {
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > prevGrade && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出3带1
        else if (lastCardType == POKER_TYPE.TripleWithSingle)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 4)
            {

            }
            int grade3 = 0;
            foreach (int key in tempMyCardHash.Keys)
            {
                if (int.Parse(tempMyCardHash[key].ToString()) == 1)
                {
                    grade3 = key;
                    break;
                }
            }
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > lastCards[1] && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(grade3);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出3带2
        else if (lastCardType == POKER_TYPE.TripleWithTwin)
        {
            // 3带1 3不带 比较只多了一个判断条件
            if (mySize < 5)
            {

            }
            int grade3 = 0;
            int grade4 = 0;
            foreach (int key in tempMyCardHash.Keys)
            {
                if (int.Parse(tempMyCardHash[key].ToString()) == 2)
                {
                    grade3 = key;
                    grade4 = key;
                    break;
                }
            }
            int tempCount = 0;
            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if (myCardsHashKey[i] > lastCards[2] && (int)tempMyCardHash[myCardsHashKey[i]] >= 3)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(grade3);
                    tempIntList.Add(grade4);
                    PromptCards.Add(tempCount, tempIntList);
                    tempCount++;
                }


            }

        }
        // 上家出炸弹
        else if (lastCardType == POKER_TYPE.FourBomb)
        {
            int tempCount = 0;
            // 4张牌可以大过上家的牌
            for (int i = 0; i <= mySize - 4; i++)
            {

                int grade0 = myCards[i];
                int grade1 = myCards[i + 1];
                int grade2 = myCards[i + 2];
                int grade3 = myCards[i + 3];


                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    if (grade0 > prevGrade)
                    {
                        // 把四张牌存进去
                        List<int> tempIntList = new List<int>();
                        tempIntList.Add(grade0);
                        tempIntList.Add(grade1);
                        tempIntList.Add(grade2);
                        tempIntList.Add(grade3);

                        PromptCards.Add(tempCount, tempIntList);
                        tempCount++;
                    }
                }
            }

        }
        // 上家出4带2 
        else if (lastCardType == POKER_TYPE.FourWithSingle)
        {
            Hashtable lastCardHash = SortCardUseHash1(lastCards);
            int lastCard4 = 0;
            foreach (int key in lastCardHash.Keys)
            {
                if ((int)lastCardHash[key] == 4)
                {
                    lastCard4 = key;
                }
            }

            int tempCount = 0;
            // 4张牌可以大过上家的牌
            for (int i = 0; i <= mySize - 4; i++)
            {
                List<int> cards = new List<int>();
                int grade0 = myCards[i];
                int grade1 = myCards[i + 1];
                int grade2 = myCards[i + 2];
                int grade3 = myCards[i + 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    cards.Add(grade0);
                    cards.Add(grade1);
                    cards.Add(grade2);
                    cards.Add(grade3);
                    if (grade0 > lastCard4)
                    {
                        int ii = 0;
                        //存进去PromptCards 然后再找一个最小的两个单
                        foreach (int key in tempMyCardHash.Keys)
                        {
                            if (int.Parse(tempMyCardHash[key].ToString()) != 4)
                            {
                                cards.Add(key);
                                ii++;
                                if (ii == 2)
                                {
                                    break;
                                }
                            }
                        }
                        PromptCards.Add(tempCount, cards);
                        tempCount++;
                    }

                }
            }
        }
        // 上家出4带2 对子
        else if (lastCardType == POKER_TYPE.FourWithTwin)
        {
            Hashtable lastCardHash = SortCardUseHash1(lastCards);
            int lastCard4 = 0;
            foreach (int key in lastCardHash.Keys)
            {
                if ((int)lastCardHash[key] == 4)
                {
                    lastCard4 = key;
                }
            }


            // 4张牌可以大过上家的牌
            int tempCount = 0;
            for (int i = 0; i <= mySize - 4; i++)
            {
                List<int> cards = new List<int>();
                int grade0 = myCards[i];
                int grade1 = myCards[i + 1];
                int grade2 = myCards[i + 2];
                int grade3 = myCards[i + 3];

                if (grade0 == grade1 && grade0 == grade2 && grade0 == grade3)
                {
                    cards.Add(grade0);
                    cards.Add(grade1);
                    cards.Add(grade2);
                    cards.Add(grade3);

                    if (grade0 > lastCard4)
                    {
                        int ii = 0;

                        foreach (int key in tempMyCardHash.Keys)
                        {
                            int tempint = int.Parse(tempMyCardHash[key].ToString());
                            if (tempint >= 2 && tempint != grade0 && tempint != 4)
                            {
                                cards.Add(key);
                                cards.Add(key);
                                ii++;
                                if (ii == 2)
                                {
                                    break;
                                }
                            }
                        }
                        PromptCards.Add(tempCount, cards);
                        tempCount++;
                    }
                }
            }
        }
        // 上家出顺子
        else if (lastCardType == POKER_TYPE.StraightSingle)
        {
            if (mySize < prevSize)
            {

            }
            else
            {
                List<int> tempMyCards = new List<int>();
                tempMyCards = myCards;
                Hashtable myCardsHash = SortCardUseHash(tempMyCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");

                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                int tempCount = 0;
                for (int i = myCardsHashKey.Count - 1; i >= prevSize - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);

                    if (myCardType == POKER_TYPE.StraightSingle)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后

                        if (myGrade2 > prevGrade2)
                        {
                            //存进去PromptCards
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }

            }

        }
        // 上家出连对
        else if (lastCardType == POKER_TYPE.StraightTwin)
        {
            if (mySize < prevSize)
            {

            }
            else
            {
                Hashtable myCardsHash = SortCardUseHash(myCards);
                if (myCardsHash.Count < prevSize)
                {
                    Debug.Log("hash的总数小于顺子的count 肯定fales");

                }
                List<int> myCardsHashKey = new List<int>();
                foreach (int key in myCardsHash.Keys)
                {
                    myCardsHashKey.Add(key);
                }
                myCardsHashKey.Sort();
                int tempCount = 0;
                for (int i = myCardsHashKey.Count - 1; i >= prevSize / 2 - 1; i--)
                {
                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize / 2; j++)
                    {
                        cards.Add(myCardsHashKey[myCardsHashKey.Count - 1 - i + j]);
                    }
                    bool tempBool = false;

                    for (int j = 0; j < cards.Count - 1; j++)
                    {
                        int w = cards[j];
                        if (cards[j + 1] - w == 1 && (int)myCardsHash[cards[j]] >= 2 && (int)myCardsHash[cards[j + 1]] >= 2)
                        {
                            tempBool = true;
                        }
                        else
                        {
                            tempBool = false;
                            break;
                        }
                    }
                    if (tempBool)
                    {
                        int myGrade2 = cards[cards.Count - 1];// 最大的牌在最后
                        int prevGrade2 = lastCards[prevSize - 1];// 最大的牌在最后
                        if (myGrade2 > prevGrade2)
                        {
                            for (int j = 0; j < prevSize / 2; j++)
                            {
                                cards.Add(cards[j]);
                            }
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }

        }
        //上家出飞机
        else if (lastCardType == POKER_TYPE.PlanePure)
        {
            if (mySize < prevSize)
            {

            }
            else
            {
                int tempCount = 0;
                for (int i = 0; i <= mySize - prevSize; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < prevSize; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            //存进去PromptCards
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }
        }
        //上家出飞机带单
        else if (lastCardType == POKER_TYPE.PlaneWithSingle)
        {
            if (mySize < prevSize)
            {

            }
            else
            {
                int tempCount = 0;
                int findTimes = mySize - prevSize + prevSize / 4;
                int feijiCount = prevSize - (prevSize / 4);
                for (int i = 0; i <= findTimes; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            Hashtable tempMyCardHash1 = SortCardUseHash1(myCards);
                            for (int ii = 0; ii < cards.Count; ii++)
                            {
                                if (tempMyCardHash1.Contains(cards[ii]))
                                {
                                    tempMyCardHash1.Remove(cards[ii]);
                                }
                            }
                            int iii = 0;
                            //存进去PromptCards 然后再找一个最小的两个单
                            foreach (int key in tempMyCardHash1.Keys)
                            {
                                if (int.Parse(tempMyCardHash1[key].ToString()) != 4)
                                {
                                    cards.Add(key);
                                    iii++;
                                    if (iii == prevSize / 4)
                                    {
                                        break;
                                    }
                                }
                            }
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }
        }

        //上家出飞机带双
        else if (lastCardType == POKER_TYPE.PlaneWithTwin)
        {

            if (mySize < prevSize)
            {

            }
            else
            {
                int tempCount = 0;
                int findTimes = mySize - prevSize + (prevSize / 5) * 2;
                int feijiCount = prevSize - (prevSize / 5) * 2;
                for (int i = 0; i <= findTimes; i++)
                {

                    List<int> cards = new List<int>();
                    for (int j = 0; j < feijiCount; j++)
                    {
                        cards.Add(myCards[i + j]);
                    }

                    POKER_TYPE myCardType = POKER_TYPE.Pass;
                    bool isRule = DDZCardRule.PopEnable(cards, out myCardType);
                    if (myCardType == POKER_TYPE.PlanePure)
                    {
                        int myGrade4 = cards[4];//
                        int prevGrade4 = lastCards[4];//

                        if (myGrade4 > prevGrade4)
                        {
                            Hashtable tempMyCardHash1 = SortCardUseHash1(myCards);
                            for (int ii = 0; ii < cards.Count; ii++)
                            {
                                if (tempMyCardHash1.Contains(cards[ii]))
                                {
                                    tempMyCardHash1.Remove(cards[ii]);
                                }
                            }

                            //存进去
                            int iii = 0;
                            //存进去PromptCards 然后再找一个最小的两个单
                            foreach (int key in tempMyCardHash1.Keys)
                            {
                                if (int.Parse(tempMyCardHash1[key].ToString()) >= 2)
                                {
                                    cards.Add(key);
                                    cards.Add(key);
                                    iii++;
                                    if (iii == prevSize / 5)
                                    {
                                        break;

                                    }
                                }
                            }
                            PromptCards.Add(tempCount, cards);
                            tempCount++;
                        }
                    }
                }
            }
        }




        // 集中判断对方不是炸弹，我出炸弹的情况
        if (lastCardType != POKER_TYPE.FourBomb)
        {

            List<int> myCardsHashKey = new List<int>();
            foreach (int key in tempMyCardHash.Keys)
            {
                myCardsHashKey.Add(key);
            }
            myCardsHashKey.Sort();
            for (int i = 0; i < myCardsHashKey.Count; i++)
            {
                if ((int)tempMyCardHash[myCardsHashKey[i]] == 4)
                {
                    List<int> tempIntList = new List<int>();
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    tempIntList.Add(myCardsHashKey[i]);
                    Debug.Log("PromptCards.Count" + PromptCards.Count);
                    PromptCards.Add(PromptCards.Count, tempIntList);

                }


            }

        }
        //if (mySize >= 2)
        //{
        //    List<int> myCardsHashKey = new List<int>();
        //    foreach (int key in tempMyCardHash.Keys)
        //    {
        //        myCardsHashKey.Add(key);
        //    }
        //    if (myCardsHashKey.Contains(53) && myCardsHashKey.Contains(54))
        //    {
        //        List<int> tempIntList = new List<int>();
        //        tempIntList.Add(53);
        //        tempIntList.Add(54);
        //        PromptCards.Add(PromptCards.Count, tempIntList);
        //    }
        //}

        return PromptCards;
    }
    #endregion

    #endregion


    private static bool compareGrade(int grade1, int grade2)
    {
        return grade1 > grade2;
    }

    #region 使用哈希去存所有的牌  顺子连对用 不用存2 王
    /// <summary>
    /// 使用哈希去存所有的牌
    /// </summary>
    /// <param name="ownCards"></param>
    /// <returns></returns>
   public static Hashtable SortCardUseHash(List<int> cards)
    {
        Hashtable temp = new Hashtable();
       
        for (int i = 0; i < cards.Count; i++)
        {
            if (cards[i] == 53)
            {
                cards.RemoveAt(i);
            }
        }
        for (int i = 0; i < cards.Count; i++)
        {
            if (cards[i] == 54)
            {
                cards.RemoveAt(i);
            }
        }
        for (int i = 0; i < 4; i++) {
            if (cards.Contains(13)) {
                cards.Remove(13);
            }
        }
        for (int i = 0; i < cards.Count; i++)
        {
            if (temp.Contains(cards[i]))
            {
                temp[cards[i]] = (int)temp[cards[i]] + 1;
            }
            else {
                temp.Add(cards[i], 1);
            }
        }
        
        return temp;
    }


    #endregion

    #region 使用哈希存所有牌 key 权重  value个数
    public static Hashtable SortCardUseHash1(List<int> cards)
    {
        Hashtable temp = new Hashtable();
        
       
        for (int i = 0; i < cards.Count; i++)
        {
            if (temp.Contains(cards[i]))
            {
                temp[cards[i]] = (int)temp[cards[i]] + 1;
            }
            else
            {
                temp.Add(cards[i], 1);
            }
        }

        return temp;
    }
    #endregion


    private int returnSingle(Hashtable tempHash) {
        int tempInt =0;
        foreach (int key in tempHash.Keys)
        {
            if (int.Parse(tempHash[key].ToString()) == 1)
            {
                tempInt = key;
                break;
            }
        }
        return tempInt;
    }

    private int returnTwin(Hashtable tempHash)
    {
        int tempInt = 0;
        foreach (int key in tempHash.Keys)
        {
            if (int.Parse(tempHash[key].ToString()) == 2)
            {
                tempInt = key;
                break;
            }
        }
        return tempInt;
    }
}
